const router = require("koa-router")();
const { loginCheck } = require("../../middlewares/loginChecks");
const { create } = require('../../controller/blogHome')
const blogValidate = require("../../validator/blog");
const { genValidator } = require("../../middlewares/validator");

router.prefix("/api/blog");

router.post('/create', loginCheck, genValidator(blogValidate), async (ctx, next) => {
  const { content, image } = ctx.request.body
  const { id: userId } = ctx.session.userInfo
  ctx.body = create({ content, image, userId })
})

module.exports = router